package sui.utils
{
    public var $format:Function = format;
}

import sui.template.Template;

var cache:Object = {};

function format(pattern:String, ... args):String
{
    var template:Template = cache[pattern] as Template;
    if (template == null)
    {
        template = new Template(pattern);
        cache[pattern] = template;
    }
    if (args.length == 1)
    {
        return template.generate(args[0]);
    }
    else if (args.length > 1)
    {
        return template.generate(args);
    }
    else
    {
        return pattern;
    }
}
